package com.mxpio.erp.common.oa.entity;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.annotation.DictValue;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.jpa.policy.impl.UUIDPolicy;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_OA_DOC_MANAGER")
@Schema(description="公文管理")
public class DocManager extends BaseEntity {

    @Id
    @Column(name = "ID_", updatable = false)
    @Generator(policy = UUIDPolicy.class)
    private String id;

    @Column(name = "MESSAGE_TYPE_")
    @Schema(description = "消息类型")
    @Dict(dicCode = "MB_ERP_OA_DOC_MSG_TYPE")
    @DictValue(value = "10=站内信,20=系统消息")
    private String messageType;

    @Column(name = "TITLE_")
    @Schema(description = "标题")
    private String title;

    @Column(name = "PRECIS_")
    @Schema(description = "摘要")
    private String precis;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Schema(description = "截至日期")
    @Column(name = "LAST_TIME_")
    private Date lastTime;

    @Column(name = "ACCEPT_TYPE_")
    @Schema(description = "接受类型")
    @Dict(dicCode = "MB_ERP_OA_DOC_ACCEPT_TYPE")
    @DictValue(value = "10=全体用户,20=指定用户")
    private String acceptType;

    @Column(name = "ACCEPT_USERS_")
    @Schema(description = "接受用户列表/,分割")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String acceptUsers;

    @Column(name = "LEVEL_")
    @Schema(description = "优先级")
    @Dict(dicCode = "MB_ERP_OA_DOC_LEVEL")
    @DictValue(value = "10=高,20=中,30=低")
    private String level;

    @Column(name = "CONTENT",columnDefinition = "TEXT")
    @Schema(description = "正文")
    private String content;

}
